// useMixin.js - 组合式 API
import { reactive, toRefs } from "vue";

export function useMixin() {
  const data = reactive({
    showPassword: true,
    username: "",
    password: "",
  });
  const clearUsername = () => {
    data.username = "";
  };
  const loginFn = () => {
    if (data.username === "" || data.password === "") {
      uni.showToast({
        title: "请输入账号和密码",
        icon: "error",
        style: {
          width: "360rpx",
        },
      });
      return;
    } else {
      uni.showToast({
        title: "登录成功",
        icon: "success",
      });
    }
  };
  return {
    loginFn,
    clearUsername,
    ...toRefs(data),
  };
}
